/*
* ============================================================================
*  Name     : CListFileEngine from ListFileEngine.h
*  Part of  : TagChanger
*  Created  : 2007/10/29 by Ma811
*  Description:
*     Engine for constructing filelist.
*  Version  : 1.0
*  Copyright: ma811ok@gmail.com
* ============================================================================
*/

#if !defined(AFX_LISTFILEENGINE_H__317AF87D_B10F_40D3_B7CC_E2FB4A3FF44A__INCLUDED_)
#define AFX_LISTFILEENGINE_H__317AF87D_B10F_40D3_B7CC_E2FB4A3FF44A__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <coecntrl.h>
#include <f32file.h>        // for CDir
#include <documenthandler.h>// for launching
#include <badesca.h>        // for CDesCArray
#include <apmstd.h>         // for TDataType

class CListFileEngine : public CBase 
{
public:
	CListFileEngine();
	virtual ~CListFileEngine();
	
	/*------------------------------------------------------------------
	Function:	GetFileList
	Class:		CListFileEngine
	Parameters:	None
	Return:		Succeed return zero, otherwise return error code	
	Descript:	Get file list of the specify directory and extenstions
	Author:		ma811
	Date:		2007/10/28
	------------------------------------------------------------------*/
	//TInt GetFileList();
	
	/*------------------------------------------------------------------
	Function:	StartFileList
	Class:		CListFileEngine
	Parameters:	None
	Return:		Succeed return zero, otherwise return error code	
	Descript:	Connect to file server and get list of files
	Author:		ma811
	Date:		2007/11/03
	------------------------------------------------------------------*/
	TInt StartFileList();
	
	/*------------------------------------------------------------------
	Function:	GetFileListItems
	Class:		CListFileEngine
	Parameters:	None
	Return:		void	
	Descript:	Copy file list to aItems
	Author:		ma811
	Date:		2007/11/03
	------------------------------------------------------------------*/
	void GetFileListItems(CDesCArray* aItems);
	
	/*------------------------------------------------------------------
	Function:	SetDirectory
	Class:		CListFileEngine
	Parameters:	None
	Return:		void	
	Descript:	The the specify path and file extension to be listed
	Author:		ma811
	Date:		2007/11/03
	------------------------------------------------------------------*/
	void SetDirectory(const TDesC& aDirectory, const TDesC& aExtension);
	
	/*------------------------------------------------------------------
	Function:	EndFileList
	Class:		CListFileEngine
	Parameters:	None
	Return:		void
	Descript:	Close file server session
	Author:		ma811
	Date:		2007/11/03
	------------------------------------------------------------------*/
	void EndFileList();
	
	TInt GetCurDir(TDes& aDir);

	TInt GetFile(TFileName& aPath, TInt aIndex);

private:
	// Define local CDir variable
	CDir* iDirList;
	
	// Fileserver session
	RFs iFsSession;
	
	// Current directory
	HBufC*	iCurDir;
	
	// Externsion type of files
	HBufC*	iFileExt;
};

#endif // !defined(AFX_LISTFILEENGINE_H__317AF87D_B10F_40D3_B7CC_E2FB4A3FF44A__INCLUDED_)
